/************************************************************************
 * @file AbstractPanelManager.h
 * @author Ian Chen
 * @version 1.0
 *
 * @section LICENSE
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
 * General Public License for more details at
 * http://www.gnu.org/licenses/lgpl.html
 *
 ************************************************************************/
#ifndef ABSTRACTPANELMANAGER_H
#define ABSTRACTPANELMANAGER_H

#include <map>
#include <vector>

using namespace std;

#include <QIcon>
#include <QMenu>

#include <pluginui/pluginui_global.h>
#include <pluginui/manager/PanelItem.h>
#include <pluginui/manager/AbstractPanelContainer.h>
#include <pluginui/manager/AbstractPanelContainerFactory.h>

namespace antu
{
namespace plugin
{
namespace ui
{
class PLUGINUISHARED_EXPORT AbstractPanelManager
{
public:

    enum PanelType
    {
        PT_None, // used to create a single widget panel
        PT_HBox, // used to create a container widget with horizontal layout
        PT_VBox, // used to create a container widget with vertical layout
        PT_Tab   // used to create a QTabWidget container widget
    };

    AbstractPanelManager();

    ~AbstractPanelManager();

    AbstractPanelContainer* container(const QString& name);

    AbstractPanelContainer* container(const QString& name, const QString& title, int factoryType = (int)AbstractPanelManager::PT_Tab,
                      Qt::DockWidgetArea area = Qt::NoDockWidgetArea,
                      Qt::DockWidgetAreas allowedAreas = Qt::LeftDockWidgetArea |
                                                         Qt::RightDockWidgetArea |
                                                         Qt::BottomDockWidgetArea,
                      QDockWidget::DockWidgetFeatures features = QDockWidget::DockWidgetClosable |
                                                                 QDockWidget::DockWidgetFloatable |
                                                                 QDockWidget::DockWidgetMovable);

    virtual void finalize() = 0;

    void registerContainerFactory(int type, AbstractPanelContainerFactory* pContainerFactory);

//protected:
//    virtual AbstractPanelContainer* createContainer(const QString& name, Qt::Orientation orientation,
//                        Qt::DockWidgetArea area = Qt::NoDockWidgetArea,
//                        Qt::DockWidgetAreas allowedAreas = Qt::LeftDockWidgetArea |
//                                                           Qt::RightDockWidgetArea |
//                                                           Qt::BottomDockWidgetArea,
//                        QDockWidget::DockWidgetFeatures features = QDockWidget::DockWidgetClosable |
//                                                                   QDockWidget::DockWidgetFloatable |
//                                                                   QDockWidget::DockWidgetMovable) = 0;

protected:
    map<QString, AbstractPanelContainer*> m_oSortedPanels;
    vector<AbstractPanelContainer*> m_oPanels;
    map<int, AbstractPanelContainerFactory*> m_oContainerFactories;

    virtual void createContainer(AbstractPanelContainer* pContainer,
                                 Qt::DockWidgetArea area = Qt::NoDockWidgetArea,
                                 Qt::DockWidgetAreas allowedAreas = Qt::LeftDockWidgetArea |
                                                                    Qt::RightDockWidgetArea |
                                                                    Qt::BottomDockWidgetArea,
                                 QDockWidget::DockWidgetFeatures features = QDockWidget::DockWidgetClosable |
                                                                            QDockWidget::DockWidgetFloatable |
                                                                            QDockWidget::DockWidgetMovable) = 0;
};
}
}
}

#endif // ABSTRACTPANELMANAGER_H
